﻿using BuildStatus.Web.BuildServer;
using BuildStatus.Web.Models;
using BuildStatus.Web.Properties;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;

namespace BuildStatus.Web.Services
{
    [Route("api/builds")]
    public class BuildsController : ApiController
    {
        // GET: api/values
        [HttpGet]
        [Route("api/builds/GetBuilds")]
        public IEnumerable<BuildProject> Get()
        {
            return BuildWatcher.Instance.GetBuildProjects();
        }

        // POST: api/values
        [HttpPost]
        [Route("api/builds/GetBuildLog")]
        public BuildLog GetBuildLog([FromBody]string buildNumber)
        {
            return BuildWatcher.Instance.GetBuildLog(buildNumber);
        }

        // POST api/values
        [HttpPost]
        [Route("api/builds/retry")]
        public void Post([FromBody]string buildNumber)
        {
            BuildWatcher.Instance.RetryBuild(buildNumber);
       }
    }
}